#!/bin/sh
#
# Run four jobs at the same time, with two Volumes.
#   Set max Vol bytes of first volume
#   to less than total backup to force Susan to use the second
#   Volume.
#
TestName="multi-client-test"
JobName=Multi-client
. scripts/functions

scripts/cleanup
scripts/copy-test-confs
/bin/cp -f scripts/multi-client-susan-dir.conf bin/susan-dir.conf

change_jobname NightlySave $JobName
start_test

cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out /dev/null
messages
@$out   ${cwd}/tmp/log1.out
@# Make sure we can contact all clients
@#setdebug level=100 dir
status client=${HOST}-fd
status client=${hostname1}-fd
status client=${hostname2}-fd
status client=${hostname3}-fd
setdebug level=1 dir
label storage=File1
TestVolume001
label storage=File1
TestVolume002
update Volume=TestVolume001 MaxVolBytes=900000000
status storage=File1
@#llist volume=TestVolume001
@#llist volume=TestVolume002
run job=${hostname1} level=Full Storage=File1 yes
run job=${hostname2} level=Full Storage=File1 yes
@# run job=${hostname3} level=Full Storage=File1 yes
status storage=File1
run job=$JobName level=Full Storage=File1 yes
@sleep 2
status dir
status storage=File1
@sleep 5
messages
wait
status storage=File1
messages
@#
@# now do a restore
@#
@$out   ${cwd}/tmp/log2.out
restore where=${cwd}/tmp/susan-restores client=${hostname}-fd select storage=File1
unmark *
mark *
done
yes
wait
messages
status dir
status storage=File1
quit
END_OF_DATA

run_susan
stop_susan

check_two_logs
#if test "$debug" -eq 1 ; then
#   diff -r ${hostname_files} ${cwd}/tmp/susan-restores/${hostname_files}
#else
#   diff -r ${hostname_files} ${cwd}/tmp/susan-restores/${hostname_files} 2>&1 >/dev/null
#fi
#dstat=$?
dstat=0
end_test
